{$APPTYPE CONSOLE}
{$IFDEF FPC}
	{$MODE DELPHI}
{$ENDIF}
{$IFDEF AguL}
	{$R+,S+,Q+,I+,C+,M+,H+,O+}
	{R-,S-,Q-,I-,C+,M-,H+,O+}
{$ELSE}
	{R+,S+,Q+,I+,C+,M+,H+,O+}
	{$R-,S-,Q-,I-,C+,M-,H+,O+}
{$ENDIF}

uses
	SysUtils, Math{$IFDEF FPC}, LineInfo{$ENDIF};

	procedure debug(const a : array of const);

	var
		i, kk, l : longint;
		s1, s2 : shortstring;
		f : text;

	begin
	{$IFDEF AguL}
		assign(f, 'log.txt');
		append(f);
		write(f, '# ');
	{$IFDEF FPC}
		GetLineInfo(ptruint(get_caller_addr(get_frame)), s1, s2, l);
		write(f, '[at function: ' + s1 + ', line: ' + inttostr(l) + '] ');
	{$ENDIF}
		kk := high(a);
		for i := 0 to kk do
			with a[i] do
				case VType of
					vtInteger : write(f, VInteger, ' ');
					vtInt64 : write(f, VInt64^, ' ');
					vtBoolean : write(f, VBoolean, ' ');
					vtChar : write(f, VChar, ' ');
					vtExtended : write(f, VExtended^, ' ');
					vtAnsiString : write(f, string(VAnsiString), ' ');
				end;
		writeln(f);
		close(f);
	{$ENDIF}
	end;

const
	TASK = '';

procedure solve();

var
	i, n : longint;

begin
{$IFDEF AguL}
	assign(input, 'input.txt');
	assign(output, 'output.txt');
{$ELSE}
	assign(input, TASK + '.in');
	assign(output, TASK + '.out');
{$ENDIF}
	reset(input);
	rewrite(output);


	
	close(input);
	close(output);
end;

procedure brute();

var
	i, n : longint;

begin
{$IFDEF AguL}
	assign(input, 'input.txt');
	assign(output, 'output.txt');
{$ELSE}
	assign(input, TASK + '.in');
	assign(output, TASK + '.out');
{$ENDIF}
	reset(input);
	rewrite(output);

	

	close(input);
	close(output);
end;

const
	TESTCOUNT = 1000;
	TIME = 2;

var
	test : longint;
	st, tm, mxtm : double;

	procedure log(msg : string);
	begin
		assign(output, 'log.txt');
		append(output);
		writeln(msg);
		close(output);
	end;

	procedure tl(tm : double);
	begin
		log('TL ' + floattostr(tm));
		halt(0);
	end;

	procedure wa(msg : string);
	begin
		log('WA ' + msg);
		halt(0);
	end;

	procedure dump(E : exception);
	begin
	{$IFDEF AguL}   
		if E = nil then exit;  
		log('Message: ' + E.Message);
	{$IFDEF FPC}
		log(BackTraceStrFunc(ExceptAddr));
		log(BackTraceStrFunc(ExceptFrames));
	{$ENDIF}
		halt(0);
	{$ENDIF}
	end;

	procedure cout(x : longint);
	begin
		assign(output, '');
		append(output);
		if x = -1 then writeln('OK') else write(x, ' ');
		close(output);
	end;

var
	jans, pans : longint;

begin
{$IFDEF AguL}
	assign(output, 'log.txt');
	rewrite(output);
	close(output);
	randomize();
	//randseed := 8753;
	log(inttostr(randseed));
	mxtm := 0;
	for test := 1 to TESTCOUNT do begin
		cout(test);

		assign(output, 'input.txt');
		rewrite(output);
		writeln(random(100000) + 1, ' ', random(100000) + 1);
		close(output);

		try
			st := now();
			solve();
			tm := (now() - st) * 24 * 3600;
			if tm > TIME then tl(tm);
			mxtm := max(mxtm, tm);
		except
			on E : Exception do
				dump(E);
		end;

		{
		assign(input, 'output.txt');
		reset(input);
		read(pans);
		close(input);

		brute();

		assign(input, 'output.txt');
		reset(input);
		read(jans);
		close(input);

		if jans <> pans then wa('E ' + inttostr(jans) + ' F ' + inttostr(pans));
		}
	
		cout(-1);
	end;
	log('OK');
	log('Max time: ' + floattostr(mxtm));
{$ELSE}
	solve();
{$ENDIF}
end.